<template>
    <div class="attention">
        <van-nav-bar title="标题" left-text="返回" left-arrow @click-left="onClickLeft" />
        <van-cell-group v-show="flat">
            <van-cell
                @click="sendItem(item.attention_name)"
                v-for="item in attentionList.list"
                :title="item.attention_name"
                center
                value="已关注"
                :label="moment(item.create_time).format('YYYY-MM-DD hh:mm:ss')"
            />
        </van-cell-group>
        <div class="empty" v-show="!flat">
            <van-empty description="暂无关注人员" />
        </div>
    </div>
</template>
<script setup>
import moment from "moment";
import { NavBar, Cell, CellGroup } from "vant";
import { userAttention } from "@/request/index";
import { onMounted, reactive, ref } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const onClickLeft = () => history.back();
let user_id = localStorage.getItem("token");
let attentionList = reactive({ list: [] });
let flat = ref(true);
onMounted(() => {
    userAttention({ user_id }).then((data) => {
        // console.log(data.rows);
        attentionList.list = data.rows;
        console.log(attentionList.list);
        if (attentionList.list.length == 0) {
            flat = false;
        }
    });
});
const sendItem = (x) => {
    // console.log(x);
    router.push({
        path: "/attentDetail",
        query: { source: x },
    });
};
</script>
<style lang="scss">
@import "../../static/style/variable.scss";
.attention {
    .van-nav-bar__text,
    .van-nav-bar .van-icon {
        color: $activeColor;
    }
}
.empty {
    margin-top: 100px;
}
</style>
